class Solution
{
public:
    vector<string> uncommonFromSentences(string A, string B)
    {
        // 将两个语句拼接
        string s = A + " " + B;

        // 分离单词
        vector<string> vRet;
        for (size_t i = 0; i < s.size(); ++i)
        {
            string temp;
            while (i < s.size() && s[i] != ' ')
            {
                temp += s[i];
                ++i;
            }

            vRet.push_back(temp);
        }

        // 统计每个单词出现的次数
        unordered_map<string, int> m;
        for (auto e : vRet)
            m[e]++;

        vRet.clear();

        // 将出现一次的单词保存在vRet中
        for (auto e : m)
        {
            if (e.second == 1)
                vRet.push_back(e.first);
        }

        return vRet;
    }
};
